package com.cctc.rds.raft.core.node;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Objects;

/**
 * Raft 节点网络信息。
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class NodeIpPort {
    private Integer nodeId;
    private String ip;
    private int port;

    @Override
    public boolean equals(Object object) {
        if (this == object) return true;
        if (object == null || getClass() != object.getClass()) return false;
        NodeIpPort that = (NodeIpPort) object;
        return nodeId == that.nodeId;
    }

    @Override
    public int hashCode() {
        return Objects.hash(nodeId);
    }

    @Override
    public String toString() {
        return "NodeIpPort{" +
                "nodeId=" + nodeId +
                ", ip='" + ip + '\'' +
                ", port=" + port +
                '}';
    }
}
